"""Definition of the DiscussionArea content type
"""

from zope.interface import implements, directlyProvides

from Products.Archetypes import atapi
from Products.ATContentTypes.content import folder
from Products.ATContentTypes.content import schemata

from utpocf.communityofpractice import communityofpracticeMessageFactory as _
from utpocf.communityofpractice.interfaces import IDiscussionArea
from utpocf.communityofpractice.config import PROJECTNAME

DiscussionAreaSchema = folder.ATFolderSchema.copy() + atapi.Schema((

    # -*- Your Archetypes field definitions here ... -*-

))

# Set storage on fields copied from ATFolderSchema, making sure
# they work well with the python bridge properties.

DiscussionAreaSchema['title'].storage = atapi.AnnotationStorage()
DiscussionAreaSchema['description'].storage = atapi.AnnotationStorage()

schemata.finalizeATCTSchema(DiscussionAreaSchema, folderish=True, moveDiscussion=False)

class DiscussionArea(folder.ATFolder):
    """Discussion area for a CoP"""
    implements(IDiscussionArea)

    portal_type = "DiscussionArea"
    schema = DiscussionAreaSchema

    title = atapi.ATFieldProperty('title')
    description = atapi.ATFieldProperty('description')

    def getRecent(self,limit=5):
        return []
#        catalog = getToolByName(self,'portal_catalog')
#        path = '/'.join(news_events.getPhysicalPath())+'/wiki'
#        results = catalog(path=path,portal_type='Document',
#                          sort_on='Date',
#                          sort_order='descending',
#                          sort_limit=limit)[:limit]
#
#
atapi.registerType(DiscussionArea, PROJECTNAME)
